{include file="public/layout" /}
<body>
<form class="layui-form" action="">
    <input type="hidden" name="id" value="{$info.id}" />
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 100px;">物流公司名字:</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" name="shipping_name" lay-verify="required" value="{$info.shipping_name}" placeholder="请输入" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 100px;">快递公司编码:</label>
        <div class="layui-input-inline layui-input-wrap">
            <input type="text" name="shipping_code" lay-verify="required" placeholder="请输入" value="{$info.shipping_code}" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid">
<!--            <a href="http://blog.csdn.net/wyp584168/article/details/79196562" target="_blank" class="ncap-btn"><i class="fa fa-truck"></i>-->
<!--                快递鸟编码参考</a>-->
            <a href="//api.kuaidi100.com/manager/openapi/download/kdbm.do" target="_blank" class="ncap-btn"><i class="fa fa-truck"></i>
                快递100编码参考</a>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 100px;">状态:</label>
        <div class="layui-input-block">
            <input type="radio" name="is_open" value="0" title="关闭" checked>
            <input type="radio" name="is_open" value="1" title="开启">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">确认</button>
        </div>
    </div>
</form>

<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script>
    layui.use(['form', 'laydate', 'util'], function(){
        var form = layui.form;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var util = layui.util;

        // 自定义验证规则
        form.verify({
            pass: [
                /^[\S]{6,12}$/,
                '密码必须6到12位，且不能出现空格'
            ]
        });

        // 指定开关事件
        // form.on('switch(switchTest)', function(data){
        //     layer.msg('开关 checked：'+ (this.checked ? 'true' : 'false'), {
        //         offset: '6px'
        //     });
        //     layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是 ON|OFF', data.othis)
        // });

        // 提交事件
        form.on('submit(demo1)', function(data){
            var index = layer.load();
            layer.close(index);

            var field = data.field; // 获取表单字段值
            $.ajax({
                type: "POST",
                url: "{:url('save')}",
                data: field,
                success: function(res){
                    console.log(res);
                    if(res.status){
                        layer.msg('提交成功');
                    }else{
                        layer.msg(res.msg);
                    }
                    setTimeout(function(){
                        parent.layer.closeAll();
                        parent.tableIns.reload()
                    },1000)
                }
            });
            return false; // 阻止默认 form 跳转
        });

        // 日期
        laydate.render({
            elem: '#date'
        });


    });
</script>
</body>
</html>